var title = "中奖名单字幕";
var config = {
    url_page: _dir + "lotteryWinnerManager.html",
    url_add: _dir + "lotteryWinnerManager_add.html",
    title_page: title + "查询",
    title_list: title + "列表",
    title_add: "添加" + title,
    title_edit: "修改" + title,
    code_list: "/lotteryCase/winner/query",
    // code_delete: "/specification/del",
    code_add: "/lotteryCase/winner/input",
     code_edit: "/lotteryCase/winner/input",
     //code_dataUpload: "/book/coverUpload",
     code_imgUpload: "/files/upload",
    pagination_01: $("#page_01")
};
$(document).ready(function () {
    if (_page == "lotteryWinnerManager_add") {
        var sendObj2 = {};
       // var editorResult=myEditor('#editor',config['code_imgUpload']);
        //初始化
        var PageInit = function () {
            var _fid = $.trim($.request.queryString["fid"]);
            var _fstaffNo = $.trim($.request.queryString["id"]);
            var _rtype = $.trim($.request.queryString["rtype"]);
            var _msgId = 0;
            this.get_fid = function () {
                return this._fid;
            };
            this.get_msgId = function () {
                return this._msgId;
            };
            this.set_fid = function (v) {
                this._fid = v;
            }
            this.set_msgId = function (v) {
                this._msgId = v;
            }
            _call(config['code_list'], sendObj2, function (res) {
                _trs = "";
                if (!res.body || res.body.length == 0) {
                    //添加
                    this.set_msgId(config['code_add']);
                    this.set_fid(0);
                    setTitle_02(config['title_add'],config['url_page']);

                }
                else {
                    $.each(res.body, function (i, v) {

                        $('#title').val(res.body.title);
                        $('#content').val(res.body.content);
                        //$('#type').val(res.body[0].type);
                        //$('#videoUrl').val(res.body[0].videoUrl);
                      //  editorResult.txt.html(res.body.content);
                    });

                }

            });
            this.setDefault = function (v) {
                    //修改
                    this.set_msgId(config['code_edit']);
                    this.set_fid(_fid);
                    setTitle_02(config['title_edit'],config['url_page']);
                    sendObj2['id'] = _fid;
                    if (getPageData(_fstaffNo)) {
                        var _v = getPageData(_fstaffNo);
                        var formObj = new Form();
                        formObj.init(_v);
                    }

            }
        };
        var _default = new PageInit();
        _default.setDefault();
        //提交事件
        $(".validate-form .submit").on("click", function () {
            var _this = $(this);
            sendObj2={};
            if ($(".validate-form").validate().form()) {
                sendObj2["title"] = $("#title").val();
                sendObj2["content"] = $("#content").val();
                _call(_default.get_msgId(), sendObj2, function (res) {
                    confirm_add_ok(res, config['url_page'], function () {
                        window.location.href = window.location.href;
                    },'stay');
                });

            }
        });
    }
    //else if (_page == "shareDisplayManager_add") {
    //    var sendObj2 = {};
    //    var editorResult=myEditor('#editor',config['code_imgUpload']);
    //    //初始化
    //    var PageInit = function () {
    //        var _fid = $.trim($.request.queryString["fid"]);
    //        var _fstaffNo = $.trim($.request.queryString["id"]);
    //        var _rtype = $.trim($.request.queryString["rtype"]);
    //        var _msgId = 0;
    //        this.get_fid = function () {
    //            return this._fid;
    //        };
    //        this.get_msgId = function () {
    //            return this._msgId;
    //        };
    //        this.set_fid = function (v) {
    //            this._fid = v;
    //        }
    //        this.set_msgId = function (v) {
    //            this._msgId = v;
    //        }
    //
    //        this.setDefault = function (v) {
    //                //添加
    //                this.set_msgId(config['code_add']);
    //                this.set_fid(0);
    //                setTitle_02(config['title_add'],config['url_page']);
    //                // new setUpload($("#idCardParent"),{'uploadUrl':config['code_dataUpload'],"urlDom":$("#videoUrl")});
    //        }
    //    };
    //    var _default = new PageInit();
    //    _default.setDefault();
    //    //提交事件
    //    $(".validate-form .submit").on("click", function () {
    //        var _this = $(this);
    //        sendObj2={};
    //        if ($(".validate-form").validate().form()) {
    //            sendObj2["title"] = $("#title").val();
    //            sendObj2["content"] = editorResult.txt.html();
    //            _call(_default.get_msgId(), sendObj2, function (res) {
    //                confirm_add_ok(res, config['url_page'], function () {
    //                    window.location.href = window.location.href;
    //                });
    //            });
    //            console.log(editorResult.txt.html())
    //        }
    //    });
    //}
});